package com.wowoai.dialog.controller;

import com.wowoai.common.response.ResponseVO;
import com.wowoai.common.userInfo.CurrentUserInfo;
import com.wowoai.common.userInfo.UserInfo;
import com.wowoai.dialog.controller.req.DialogReq;
import com.wowoai.dialog.service.DialogServiceI;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ai会话
 */
@RestController
@RequestMapping("/dialog")
public class DialogController {

    private final DialogServiceI dialogServiceI;

    public DialogController(DialogServiceI dialogServiceI){
        Assert.notNull(dialogServiceI,"dialogServiceI 不能为空");
        this.dialogServiceI = dialogServiceI;
    }

    @PostMapping("/saveDialogContent")
    public ResponseVO<Void> saveDialogContent(@RequestBody DialogReq dialogReq){
        UserInfo userInfo = CurrentUserInfo.getUserInfo();
        dialogServiceI.saveDialogContent(userInfo,dialogReq.getProblem(),dialogReq.getAnswer());
        return ResponseVO.success(null);
    }
}
